package com.rzico.quartz.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;


/**
 * @author zhongzm
 * @date 2020/2/2
 * 通过监听，开辟线程，执行定时任务
 */

@Component
@Slf4j
public class MyApplicationListener implements ApplicationListener<ContextRefreshedEvent> {


    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        log.info("-------------bean初始化完毕-------------");
        DataSourceJobThread myThread = (DataSourceJobThread) event.getApplicationContext().getBean(
                "dataSourceJobThread");
        myThread.start();
    }

}
